package com.kaka.serviceimpl;

import com.kaka.dao.StudentDao;
import com.kaka.dao.TeacherDao;
import com.kaka.daoimpl.StudentDaoImpl;
import com.kaka.daoimpl.TeacherDaoImpl;
import com.kaka.javabean.Student;
import com.kaka.javabean.Teacher;
import com.kaka.service.StudentService;
import com.kaka.util.SMSUtil;

import java.util.List;

public class StudentServiceImpl implements StudentService {

    private final StudentDao studentDao = new StudentDaoImpl();
    private final TeacherDao teacherDao = new TeacherDaoImpl();

    @Override
    public List<Teacher> showAllTeacher() {
        return teacherDao.selectAll();
    }

    @Override
    public void chooseTeacher(int tid, int sid) {
        SMSUtil.check(studentDao.updateTidBySid(tid, sid));
    }

    @Override
    public Student ShowMyInfo(int sid) {
        List<Student> studentList = studentDao.selectBySid(sid);
        return studentList.get(0);
    }

    @Override
    public void updateStudentPassword(int sid, String newPassword) {
        int num = studentDao.updatePasswordBySid(sid, newPassword);
        SMSUtil.check(num);
    }
}
